package bjut.core.zookeeper;

import bjut.core.utils.CuratorUtil;
import bjut.core.interfaces.ServiceRegistry;
import org.apache.curator.framework.CuratorFramework;

import java.net.InetSocketAddress;

/**
 * @Author: zhuzhiming
 * @Date: 2022/4/9 16:48
 */
public class ZkServiceRegistryImpl implements ServiceRegistry {
    @Override
    public void registerService(String serviceName, InetSocketAddress inetSocketAddress) {
        String registerPath = CuratorUtil.ZRPC_ROOT_PATH + serviceName + inetSocketAddress;
        CuratorFramework zkClient = CuratorUtil.getZkClient();
        CuratorUtil.createPersistentNode(zkClient, registerPath);
    }
}
